<?php
class User extends AppModel
{
    var $name='User';
    var $validate = array(
        'username' => array(
                'alphaNumeric'=>array(
                        'rule'=>'alphaNumeric',
                        'message' => '用户名只能由字母和数字构成'
                 ),
               'between' => array(
                        'rule' => array('between',5,20),
                        'message' => '长度必须5到20之间'
                ),
                'isUnique' => array(
                    'rule' => 'isUnique',
                    'message' =>'该用户名已经存在了'
                )
            ),
        'password2' => array( 
            'rule' => array('minlength',6),
            'message' => '密码最少6个字符'
        ),
        'password' => array(
            'rule' => 'checkPassword',
            'message' => '密码两次输入不一致'
        )
    );
    
    function checkPassword($data)
    {
        if($this->data['User']['password2Hash'] == $data['password'])
            return true;
        return false;
    }
    
}
?>